﻿@model Huirui.Cavan.Presentation.ViewModel.PurchaseModule.IPayViewModel
@{
    Layout = null;
}

@using (Html.BeginForm(ActionConst.SEARCH, ControllerConst.PAY, FormMethod.Post))
{
    <div class="tool_bar">
        <input id="pay_query" type="submit" style="display: none;" />
        <input id="pay_reset" type="reset" style="display: none" />
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-undo'" onclick="javascript:$('#pay_reset').click()">重置</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-search'" onclick="javascript:$('#pay_query').click()">查询</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-print'">打印</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-collapse'" onclick="toggleHeard()">折叠/展开</a>
    </div>
    <table class="form_heard">
        <tr>
            <td class="c100">
                <label>
                    日期:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.SearchParam.StartDate, new { id = "payDateStart", @class = "Wdate", @type = "text", @onfocus = "WdatePicker({wdate:true,isShowClear:false,readOnly:true,skin:'whyGreen',maxDate:'%y-%M-%d'})" })
            </td>
            <td class="c30">
                <label>
                    至</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.SearchParam.EndDate, new { id = "payDateEnd", @class = "Wdate", @type = "text", @onfocus = "WdatePicker({wdate:true,isShowClear:false,readOnly:true,skin:'whyGreen'})" })
            </td>
        </tr>
        <tr>
            <td class="c100">
                <label>供应商:</label>
            </td>
            <td class="c160">
                @Html.TextBox("supplierNameForPay", "", new { id = "supplierNameForPay" })
                @Html.HiddenFor(m => m.SearchParam.SupplierCode,  new { id = "supplierCodeForPay" })
            </td>
            <td class="c100">
                <label>付款编号:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.SearchParam.ID,  new { id = "idForPay" })
            </td>
        </tr>
    </table>
    <table id="paylist_gd" class="easyui-datagrid">
    </table>
    <div id="paylist_tb">
        <a href="#" class="easyui-linkbutton" iconcls="icon-print" plain="true" onclick="javascript:alert('打印列表')">打印列表</a>
        <a href="#" class="easyui-linkbutton" iconcls="icon-excel" plain="true" onclick="javascript:alert('引出')">引出</a>
    </div>
}
<script type="text/javascript">
    $(function () {
        $('#paylist_gd').datagrid({
            idfield: 'Id',
            toolbar: '#paylist_tb',
            title: '付款单列表',
            singleSelect: 'true',
            selectOnCheck: 'true',
            fitColumns: 'true',
            pagination: 'true',
            columns: [[
                 { field: 'ck', checkbox: true, width: 10 },
                 { field: 'Id', title: '付款编号', width: 80, hidden: true },
                 {
                     field: 'NoPrefixId', title: '付款编号', width: 80, formatter: function (value, row, index) {
                         return '<a onclick=addTab("付款单","center_tt","/pay/add/' + row.Id + '") href="#">' + value + '</a>';
                     }
                 },
                 { field: 'PayDate', title: '日期', width: 80 },
                 { field: 'SupplierName', title: '供应商', width: 80 },
                 { field: 'Currency', title: '币别', width: 80 },
                 { field: 'CurrencyRate', title: '汇率', width: 80 },
                 { field: 'Amount', title: '金额', width: 80 },
                 { field: 'AccountName', title: '付款帐户', width: 80 },
                 { field: 'AccountNumber', title: '支付号', width: 80 },
                 { field: 'Producer', title: '制单员', width: 80 },
                 { field: 'Remark', title: '备注', width: 80 }
            ]]
        });

        $("form[action^='/pay/search']").submit(function () {
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                success: function (result) {
                    if (result.total > 0) {
                        $('#paylist_gd').datagrid({
                            idfield: 'Id',
                            singleSelect: 'true',
                            selectOnCheck: 'true',
                            fitColumns: 'true',
                            pagination: 'true',
                            data: result
                        });
                    }
                    else {
                        $('#paylist_gd').datagrid('loadData', { total: 0, rows: [] });
                    }
                },
                error: function () {
                    alert('系统繁忙，请稍候再试');
                }
            })

            return false;
        });
    });
</script>
